package lxt.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import lxt.dao.QueryDataDao;
import lxt.service.QueryDataService;

public class QueryDataServiceImpl implements QueryDataService {
	private QueryDataDao queryDataDao;

	public void setQueryDataDao(QueryDataDao queryDataDao) {
		this.queryDataDao = queryDataDao;
	}

	public List<Map<String, Object>> queryOweForPage(String clientName,
			String orderId, String startDate, String endDate, Integer offset,
			Integer pageCounts) throws Exception {
		return queryDataDao.queryOweForPage(clientName, orderId, startDate,
				endDate, offset, pageCounts);
	}

	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> queryOweDetail(String clientId,
			String orderId) throws Exception {
		return (List<Map<String, Object>>) queryDataDao.queryOweDetail(
				clientId, orderId);
	}

	public List<Map<String, Object>> queryChargeHistory(String clientId,
			String orderId) throws Exception {
		List<Map<String, Object>> history = (List<Map<String, Object>>) queryDataDao
				.queryChargeHistory(clientId, orderId);
		List<Map<String, Object>> resume = queryDataDao.queryResumeForHistory(
				clientId, orderId);
		if(resume != null && resume.size() > 0){
			if (history == null)
				history = new ArrayList<Map<String, Object>>();
			history.add(resume.get(0));
		}
		return history;
	}

	public List<Map<String, Object>> loadFeeBySendClient(String clientName, String linkMan,
			String startDate, String endDate, Integer offset, Integer limit)
			throws Exception {
		List<Map<String, Object>> list = queryDataDao.loadFeeBySendClientForPage(clientName, linkMan, startDate, endDate,
				offset, limit);
		List<Map<String, Object>> resume = queryDataDao.loadFeeBySendClientForResume(clientName, linkMan, startDate, endDate);
		if(resume != null && resume.size() > 0){
			if(list == null)
				list = new ArrayList<Map<String, Object>>();
			list.add(resume.get(0));
		}
		return list;
	}

	public List<Map<String, Object>> loadFeeByTruck(String truckId,
			String truckName, String startDate, String endDate, Integer offset,
			Integer limit) throws Exception {
		return queryDataDao.loadFeeByTruckForPage(truckId, truckName, startDate, endDate,
				offset, limit);
	}

	public List<Map<String, Object>> loadFeeByDriver(String driverName,
			String startDate, String endDate, Integer offset, Integer limit)
			throws Exception {
		return queryDataDao.loadFeeByDriverForPage(driverName, startDate, endDate,
				offset, limit);
	}
}
